﻿#if UNIT_TEST
using System.IO;
using NUnit.Framework;
using SmartBoard.BackGround.Data;
using SmartBoard.Background.Serialization;

namespace SmartBoard.BackGround._Tests
{
    [TestFixture]
    public class TestV11SerialzationStrategy
    {
        private V10BackgroundData _data;
        private V11SerializationStrategy _strategy;

        [SetUp]
        public void SetUp()
        {
            _data = new V10BackgroundData
            {
                A = 175,
                R = 250,
                G = 127,
                B = 128
            };

            _strategy = new V11SerializationStrategy();
        }

        [TearDown]
        public void TearDown()
        {

        }

        [Test]
        public void TestSerializeAndDeSerialize()
        {
            var stream = new MemoryStream();
            _strategy.Serialize(stream, _data);

            Assert.IsTrue(stream.Length != 0);

            stream.Position = 0;
            var obj = _strategy.Deserialize(stream) as V10BackgroundData;

            Assert.IsNotNull(obj);
            Assert.AreEqual(obj.A, _data.A);
            Assert.AreEqual(obj.R, _data.R);
            Assert.AreEqual(obj.G, _data.G);
            Assert.AreEqual(obj.B, _data.B);
        }
    }
}
#endif
